/**
 * Created by gaoyj on 2018/6/30.
 */
window.onload = function (ev) {
    topbar.hide();
};

var modifyAlipayForm = $("#modifyAlipayForm").validate({
    rules: {
        id: {
            required: true,
        },  aliPayAccount: {
            required: true
        }
    }
});

function unLockUser(v) {
    $.ajax({
        type: "post",
        url: 'UserController/unLockUser',
        data: {account: $("#account").val(), state: v},
        dataType: "json",
        async: false,
        cache: false,
        success: function (data) {
            if (data.success) {
                layer.msg('操作成功');
            } else {
                layer.msg(data.message)
            }
        }
    });
}

function getAlipayInfo() {
    if ($("#account").val() == "") {
        layer.msg("请输入会员编号")
    }
    $.ajax({
        type: "post",
        url: 'UserManagerController/getAlipayInfo',
        data: {account: $("#account").val()},
        dataType: "json",
        async: false,
        cache: false,
        success: function (data) {
            if (data != null) {
                $("#hidId").val(data.id);
                $("#realName").val(data.realName)
                $("#oldAliPayAccount").val(data.aliPayAccount)
                $("#modifyAlipayModal").modal("show")
            } else {
                layer.msg("查询会员支付宝信息失败")
            }
        }
    });
}

$("#modifyAlipaySubmit").click(function () {
    var v = $("#modifyAlipayForm").valid();
    if (!v) {
        layer.msg("参数错误")
        return;
    }
    if ($("#account").val() == "") {
        layer.msg("请输入会员编号")
    }
    $.ajax({
        type: "post",
        url: 'UserManagerController/updateAlipay',
        data: $("#modifyAlipayForm").serialize() + "&account=" + $("#account").val(),
        dataType: "json",
        async: false,
        cache: false,
        success: function (data) {
            if (data.returnCode == 200) {
                layer.msg(data.data.message)
            } else {
                layer.msg("修改查询会员支付宝信息失败")
            }
        }
    });
})

function updatePayPwd() {
    $.ajax({
        type: "post",
        url: 'UserController/updatePayPwd',
        data: {account: $("#account").val(), payPwd: $("#payPwd").val()},
        dataType: "json",
        async: false,
        cache: false,
        success: function (data) {
            if (data.success) {
                layer.msg('操作成功');
                $("#modifyAlipayModal").modal("hide");
            } else {
                layer.msg(data.message)
            }
        }
    });
}
$("#ipUnlock").click(function () {
    $.ajax({
        type: "post",
        url: '/UserController/unLockUserIp',
        traditional: true,
        data: {
            ip: $("#ip").val()
        },
        success: function (data) {
            if (data.success) {
                layer.msg(data.message)
            } else {
                layer.msg(data.message)
            }
        }
    });
})




